package com.clarkware.junitperf;

import java.util.ArrayList;
import java.util.Random;

import VO.PoliticaVO;

import com.sse.logica.ManejadorAlertas;
import com.sse.sensor.TipoSensor;
import com.sse.sensor.impl.SensorHumo;
import com.sse.util.TramaUtil;

import conexion.ManejadorPoliticas;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * The <code>ExampleTestCase</code> is an example stateless
 * <code>TestCase</code>.
 * 
 * @author <b>Mike Clark</b>
 * @author Clarkware Consulting, Inc.
 */

public class ExampleTestCase extends TestCase {
	
	ArrayList<PoliticaVO> lPoliticas;
	ArrayList<Long> politicas;

	public ExampleTestCase(String name, ArrayList<PoliticaVO> lPoliticas_,ArrayList<Long> politicas_ ) throws Exception {
		super(name);
		
		new ManejadorPoliticas();
		lPoliticas = lPoliticas_;
		politicas = politicas_;
		
	}

	protected void setUp() {
	}

	protected void tearDown() {
	}

	/*public void testRND1() throws Exception {
		double r = 0.1;
		for (int i = 0; i < 10; i++) {
			Thread.sleep(1);
			System.out.println("RND1: " + i + "," + r);
			r = 1 - Math.pow(10, (r - 1));
		}
	}*/

	/*public void testRND2() throws Exception {

		int i = 0;
		double r = 0.1;
		while (i < 10) {
			Thread.sleep(1);
			i++;
			System.out.println("RND2: " + i + "," + r);
			r = 1 - Math.pow(10, (r - 1));
		}
	}*/
	
	public void testEventoHumo() throws Exception {
		
		for (int i = 0; i < lPoliticas.size(); i++) {
			politicas.add(TramaUtil.convertirValoresATrama(
					lPoliticas.get(i).getCodigoInmueble(), 
					lPoliticas.get(i).getCodigoSensor(),
					lPoliticas.get(i).getCodigoEvento(), 
					lPoliticas.get(i).getTipoSensor(), 
					lPoliticas.get(i).getCodigoTagId()));
		}

		ManejadorAlertas Alertas = new ManejadorAlertas(politicas, lPoliticas);
		
		Random rnd = new Random();
		
		long evento = TramaUtil.convertirValoresATrama(
					rnd.nextInt(50), 
					rnd.nextInt(50),
					rnd.nextInt(1),
					rnd.nextInt(4),
					rnd.nextInt(50));
		
		Alertas.esAlerta(evento);
	}

	public static Test suite() {
		return new TestSuite(ExampleTestCase.class);
	}

	public static void main(String args[]) {
		junit.textui.TestRunner.run(suite());
	}
}
